#!/bin/sh
# This wrapper exists so we can call `Easyubuntu' in gksu or
# kdesu, which means the password dialog the users sees contains
# the pretty version Easyubuntu and not `python easyubuntu.in'
#
# Bit ugly though, suggestions are welcome.

MESSAGE="<b>Enter your password to run administrative tasks</b>

The application EasyUbuntu lets you modify essential parts of your system."

# Change directory to the easyubuntu lib.
#
pushd /usr/lib/easyubuntu > /dev/null 2>&1

# Check what we're running. SESSION_MANAGER and run appropriate command.
#
if [ "$DESKTOP_SESSION" = "gnome" ]; then
	RUNNING=gnome
fi
if [ "$KDE_FULL_SESSION" = "true" ]; then
	RUNNING=kde
fi

case $RUNNING in
	"gnome")
		echo "You appear to be running Gnome, using gksudo"
		test -x /usr/bin/gksudo && gksu --title "$TITLE" --message "$MESSAGE" -- python ./easyubuntu.in
		;;

	"kde")
		echo "You appear to be running KDE, using kdesu"
    		test -x /usr/bin/kdesu && kdesu python ./easyubuntu.in
		;;

	*)
		echo "Unable to determine desktop environment, falling back to gksudo"
		test -x /usr/bin/gksudo && gksu --title "$TITLE" --message "$MESSAGE" -- python ./easyubuntu.in
		;;
esac

# Back to where we came from!
#
popd > /dev/null 2>&1
